import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description
 * User: wen
 * Date:2022-02-15
 * TIME:9:21
 */
public class TestDemo {
    public static void main(String[] args) {
        //7. 计算1/1-1/2+1/3-1/4+1/5 …… + 1/99 - 1/100 的值。
        double num = 0.0;
        double sum = 0.0;
        double fac = 0.0;
        for(int i = 1; i <= 100; i++){
            fac = 1/i;
            sum += fac;
            fac = fac*(-1);
        }
        System.out.println(sum);
    }
    public static void main5(String[] args) {
        //1*1=1
        //1*2=2 2*2=4
        //1*3=3 2*3=6 3*3=9
        int i = 0;
        int j = 0;
        for (i = 1; i <= 9; i++) {
            for (j = 1; j <= i; j++) {
                System.out.printf("%d*%d=%2d ",j,i,i*j);
            }
            System.out.println("");
        }
    }
    public static void main4(String[] args) {
        int year = 1000;
        for (year = 1000; year <=2000 ; year++) {
            if((year % 4 ==0 && year % 100 != 0) || year % 400 == 0){
                System.out.println(year);
                continue;
            }
        }

    }
    public static void main3(String[] args) {
        //2. 打印1-100之间所有的素数
        int j = 0;
        for (j = 2; j < 100; j++) {
            for (int i = 2; i < j; i++) {
                if(j % i != 0){
                    System.out.println(j);
                    //怎么实现让他每一个都不为0，但是要打印拿出来他
                }
                else{
                    //System.out.println(j);
                    break;
                }
            }
        }

    }
    public static void main2(String[] args) {
        //2. 判定一个数字是否是素数
        int num = 14;
        for (int i = 2; i < num; i++) {
            if(num % i == 0){
                System.out.println("不是素数");
                break;
            }
            else{
                System.out.println("是素数");
                break;
            }
        }
    }
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int age = scanner.nextInt();
        //int age = 29;
        if(age > 0 && age <= 18){
            System.out.println("少年");
        }
        else if(age >= 19 && age <= 28){
            System.out.println("青年");
        }
        else if(age >= 29 && age <= 55){
            System.out.println("中年");
        }
        else{
            System.out.println("老年");
        }
    }
}
